
# 不允许修改的列表

# 定义用小括号
my_tuple_1 = (1, "hello", True)
my_tuple_2 = ()
my_tuple_3 = tuple()
print(type(my_tuple_1), my_tuple_1)
print(type(my_tuple_2), my_tuple_2)
print(type(my_tuple_3), my_tuple_3)

my_tuple_4 = (2,) # 一个元素的元组需要再写个逗号，否则认为是一个变量
print(type(my_tuple_4), my_tuple_4)
my_float_5 = (3.5)
print(type(my_float_5), my_float_5)

# 元组内嵌套的列表可以修改
my_t_6 = (1, 2.5, "abc", [3.4, 1.5, "def"])
# my_t_6[0] = 2 # 错误
my_t_6[3][0] = "test1"
my_t_6[3][1] = "test2"
my_t_6[3][2] = 2.5
print(my_t_6) # 元组内嵌套的列表可以修改